﻿@page "/Admin/Profiles"
@using BlazorAdmin.Web.Shared.Components
@attribute [TabItemOption(Text = "个人中心", Icon = "fa-solid fa-suitcase")]

<div class="tab-scroll-body">
    <Card IsShadow="true">
        <HeaderTemplate>基本资料</HeaderTemplate>
        <BodyTemplate>
            <ValidateForm OnValidSubmit="OnSaveDisplayName" Model="currentUser">
                <div class="row g-3 form-inline">
                    <div class="col-12 col-sm-6">
                        <Display @bind-Value="@currentUser.UserName" />
                    </div>
                    <div class="col-12 col-sm-6">
                        <BootstrapInput @bind-Value="@currentUser.DisplayName" />
                    </div>
                    <div class="col-12 justify-content-end">
                        <Button ButtonType="ButtonType.Submit" Icon="fa-solid fa-floppy-disk" Text="保存" />
                    </div>
                </div>
            </ValidateForm>
        </BodyTemplate>
    </Card>
    
    <Card IsShadow="true">
        <HeaderTemplate>修改密码</HeaderTemplate>
        <BodyTemplate>
            <AdminAlert Text="此修改密码模块不是修改登录域的密码" IsShow="true" />
            <ValidateForm OnValidSubmit="OnSavePassword" Model="currentUser">
                <div class="row g-3 form-inline">
                    <div class="col-12 col-sm-6">
                        <BootstrapPassword @bind-Value="@currentUser.Password" DisplayText="原密码" />
                    </div>
                    <div class="col-12 col-sm-6 d-none d-sm-block">
                    </div>
                    <div class="col-12 col-sm-6">
                        <BootstrapPassword @bind-Value="@currentUser.NewPassword" />
                    </div>
                    <div class="col-12 col-sm-6">
                        <BootstrapPassword @bind-Value="@currentUser.ConfirmPassword" />
                    </div>
                    <div class="col-12 justify-content-end">
                        <Button ButtonType="ButtonType.Submit" Icon="fa-solid fa-floppy-disk" Text="保存" />
                    </div>
                </div>
            </ValidateForm>
        </BodyTemplate>
    </Card>

    <Card IsShadow="true">
        <HeaderTemplate>个人头像</HeaderTemplate>
        <BodyTemplate>
            <div class="row g-3 form-inline">
            <div class="col-12 col-sm-6">
                <CardUpload TValue="string" IsSingle="true" DefaultFileList="previewFileList" OnChange="OnSaveIcon" OnDelete="OnDeleteIcon" />
            </div>
        </div>
        </BodyTemplate>
    </Card>

    <AdminCard HeaderText="默认应用" AuthorizeKey="SaveApp">
        <div class="row g-3 form-inline">
            <div class="col-12 col-sm-6">
                <Dropdown Items="apps" @bind-Value="currentUser.App" />
            </div>
            <Block Condition="true">
                <div class="col-12 col-sm-6 justify-content-end">
                    <Button Icon="fa-solid fa-floppy-disk" Text="保存" OnClickWithoutRender="OnSaveApp" />
                </div>
            </Block>
        </div>
    </AdminCard>
</div>